//
//  AppTools.m
//  豆瓣2
//
//  Created by dllo on 15/12/18.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "AppTools.h"
#import "AFNetworking.h"
@implementation AppTools

+(void)getMovieFromJsonWithfilmName:(NSString *)filed block:(AppToolsBlock)block error:(AppToolsErrorBlock)errorblock{
    
    AFNetworkReachabilityManager *netWorkManager = [AFNetworkReachabilityManager sharedManager];
    NSString *url_string = [NSString stringWithFormat:@"%@",filed];
    
    
    
    //[NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];  代表支持所有的接口类型
    //请求管理者 所有的网络请求,均有manager发起
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    [manager GET:url_string parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        
        [netWorkManager stopMonitoring];
        
        NSLog(@"使用AFN进行get请求 ===  %@",responseObject);
        
        block (responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        
        NSLog(@"失败==== %@",error);
        
        errorblock (error);
        
    }];
    

    
}
@end
